package be.aquafin.klipdf.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;

import org.hibernate.annotations.Type;

import com.vividsolutions.jts.geom.Geometry;

@Entity
public class SpatialPipe extends SpatialObject implements Comparable<SpatialObject> {
	
	@Id
	private String uid;

	@Type(type="org.hibernate.spatial.GeometryType")
	@Column(name= "geoPipe", nullable= false)
	private Geometry geometry;
	
	@Override
	public String getKey() {
		return uid;
	}

	@Override
	public void setKey(String uid) {
		this.uid = uid;
	}

	@Override
	public Geometry getGeometry() {
		return this.geometry;
	}
	
	@Override
	public void setGeometry(Geometry geometry) {
		this.geometry = geometry;
	}
	
	@Override
	public int compareTo(SpatialObject o) {
		if(!(o instanceof SpatialPipe)) {
			throw new IllegalArgumentException("unable to compare");
		}
		SpatialPipe spatialPipe = (SpatialPipe) o;
		return this.getKey().compareTo(spatialPipe.getKey());
	}

	@Override
	public String toString() {
		return this.uid;
	}
	
}
